/*
 * invulgotracker
 * Copyright (C) Thomas Andersen 2011 <thomas.1.andersen@gmail.com>
 *
 * invulgotracker is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * invulgotracker is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef INVULGOTRACKERAPP_H
#define INVULGOTRACKERAPP_H

#include <gtk/gtk.h>
#include <glade/glade.h>

#include "time-view.h"
#include "task-view.h"
#include "summary-view.h"
#include "i-notify.h"
#include "time-used-thread.h"

class InvulgoTrackerApp : INotify
{
public:
    InvulgoTrackerApp();
    virtual ~InvulgoTrackerApp();
    void Run();
    static InvulgoTrackerApp *app;
    static GladeXML *gxml;

    void AddTimeByPath(GtkTreePath *path);
    void TimeEdit(gchar *pathString, gchar *newText);
    void TaskEdit(gchar *pathString, gchar *newText);
    void TimeAdd();
    void TimeInsert();
    void TimeDelete();
    void TaskAdd();
    void TaskAddRoot();
    void TaskDelete();
    void AboutShow();
    void HelpShow();
    void AddTimeByTask(TaskId taskId);
    void BuildTaskMenu(GtkWidget *item, GCallback callback, list<TaskId *> &menuTaskList);
    void CalendarSelected(GtkCalendar *calendar);
#if GTK_CHECK_VERSION(2,12,0)
    void SetTooltip(GtkTooltip *tooltip);
#else
    void SetTooltip(GtkTooltips *tooltip);
#endif
    void UpdateSummary(int year, int month, int day);
    TaskView &GetTaskView() { return taskView; }
    void Exit();
    bool BlockMenu();
    void Notify(int event);
    void ShowPrefs();
    void TaskDetails();
    void UsedCalcDone();
    void SetSickday();
    void SetHoliday();
private:
    static gboolean time_handler(InvulgoTrackerApp *t);
    void CreateMainWindow();
    void CreateTrayIcon();
    void SetSavedSizes();
    void InsertEndTask();
    void TimeSaveAndCalc();

    /* Private attributes. */
    GtkWidget       *mainWindow;
    GtkStatusIcon   *trayIcon;
    TaskView        taskView;
    TimeView        timeView;
    SummaryView     summaryView;
    TaskId          lastTaskId;
    TaskTime        lastTaskTime;
    bool            savePrefsShowSummaryPercentage;
    const gchar     *saveColorDeadline;
    const gchar     *saveColorDone;
    pthread_mutex_t mutexTimeView;
    TimeUsedThread  *timeUsedCalc;
    GtkWidget       *statusBar;
};

#endif // INVULGOTRACKERAPP_H
